package com.ceadeal.admin.repository.impl;

import com.ceadeal.admin.entity.User;
import com.ceadeal.admin.repository.BaseRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.persistence.Query;

/**
 * 功能描述: UserRepositoryImpl
 *
 * 作者: Yzw
 * 日期: 2017-03-24 16:04:16
 */
@SuppressWarnings("JpaQlInspection")
public class UserRepositoryImpl extends BaseRepository {

    private static Logger log = LoggerFactory.getLogger(UserRepositoryImpl.class);

    public User getUserInfo(Long id) {
        log.info("测试自定义方法 => 开始");

        String sql = "select u from User u where u.id = :id";
        Query query = getEntityManager().createQuery(sql);
        query.setParameter("id", id);

        User user = (User) query.getSingleResult();

        log.info("测试自定义方法 => 结束");
        return user;
    }

}
